package com.zh.repo.controller;

import com.zh.repo.common.BakeOvenInfoMethods;
import com.zh.repo.entity.vo.BakeOvenInfo;
import com.zh.repo.entity.vo.BakeOvenInfoView;
import com.zh.repo.service.BakeOvenInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author:
 * @time: 2025-05-11 12:07
 * @version: 1.0
 */
@RestController
@RequestMapping("/workflow")
public class BakeOvenInfoController {
    @Resource
    private BakeOvenInfoService bakeOvenInfoService;

    @GetMapping("/home")
    public String testGetMapParams(@RequestParam Map<String,Object> params){
        return "name：" + params.get("name") + "<br>age：" + params.get("age");
    }

    @GetMapping("/getBakeOvenList")
    public List<BakeOvenInfo> listMapBakeOvenInfo(@RequestParam Map<String,String>mapParams) throws ParseException {
        List<BakeOvenInfo> bakeOvenInfoListResult= BakeOvenInfoMethods.getBakeOvenInfoFrontList(mapParams);
        return bakeOvenInfoListResult;
    }

    /**
     * 传递日期值参数
     * @param mapParams
     * @return
     * @throws ParseException
     */
    @GetMapping("/getBakeOvenMap")
    public Map  listMapBakeOvenInfo2(@RequestParam Map<String,String>mapParams) throws ParseException {
        List<BakeOvenInfo> bakeOvenInfoListResult= BakeOvenInfoMethods.getBakeOvenInfoFrontList(mapParams);
        Map<String,Object>map=new HashMap<>();
        map.put("monthsList",bakeOvenInfoListResult);
        return map;
    }
    @GetMapping("/getBakeOvenInfo/{requestid}")
    public BakeOvenInfo getBakeOvenInfo(@PathVariable("requestid") Integer requestid){
        BakeOvenInfo bakeOvenInfo=bakeOvenInfoService.getBakeOvenInfoOne(requestid);
        return bakeOvenInfo;
    }

    @GetMapping("/getBakeOvenInfoViewList")
    public List<BakeOvenInfoView> listMapBakeOvenInfoView(@RequestParam Map<String,String>mapParams) throws ParseException {
        List<BakeOvenInfoView> bakeOvenInfoListResult=BakeOvenInfoMethods.getBakeOvenInfoViewFrontList(mapParams);
        return bakeOvenInfoListResult;
    }


    @GetMapping("/allBakeOvenList")
    public List<BakeOvenInfo> listAllBakenOvenInfo(){
        Map map=new LinkedHashMap();
        return bakeOvenInfoService.getBakeOvenInfoList(map);
    }
}
